*****Sigman and Lindberg 2017*****
*****Democracy for All*****
**Replication for Table 11 in the Appendix**

**Version: July 2017**

clear
use "v-dem_coder2.dta"
set more off, permanently
set matsize 11000
log using "Table11", replace
ssc inst kappa2
ssc inst krippalpha

**Calculate Cohen's Kappa Statistic
*The "combined" statistics reported in the output are the ones reported in Table 11.
*For the weighted versions (w) and (w2), the statistics in column labeled "K" are the ones reported in Table 11.


keep country_id historical_date year coder_id v2clacjust
drop if v2clacjust == .
  reshape wide v2clacjust, i(country_id historical_date year) j(coder)
kap v2clacjust19 - v2clacjust3882
kappa2 v2clacjust19 - v2clacjust3882, wgt(w)
kappa2 v2clacjust19 - v2clacjust3882, wgt(w2)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2clsocgrp
drop if v2clsocgrp == .
  reshape wide v2clsocgrp, i(country_id historical_date year) j(coder)
kap v2clsocgrp19 - v2clsocgrp3882
kappa2 v2clsocgrp19 - v2clsocgrp3882, wgt(w)
kappa2 v2clsocgrp19 - v2clsocgrp3882, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2peedueq
drop if v2peedueq == .
  reshape wide v2peedueq, i(country_id historical_date year) j(coder)
kap v2peedueq19-v2peedueq3879
kappa2 v2peedueq19-v2peedueq3879, wgt(w)
kappa2 v2peedueq19-v2peedueq3879, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pehealth
drop if v2pehealth == .
  reshape wide v2pehealth, i(country_id historical_date year) j(coder)
kap v2pehealth19-v2pehealth3879
kappa2 v2pehealth19-v2pehealth3879, wgt(w)
kappa2 v2pehealth19-v2pehealth3879, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2dlencmps
drop if v2dlencmps == .
  reshape wide v2dlencmps, i(country_id historical_date year) j(coder)
kap v2dlencmps19-v2dlencmps3881
kappa2 v2dlencmps19-v2dlencmps3881, wgt(w)
kappa2 v2dlencmps19-v2dlencmps3881, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2dlunivl
drop if v2dlunivl == .
  reshape wide v2dlunivl, i(country_id historical_date year) j(coder)
kap v2dlunivl19-v2dlunivl3881
kappa2 v2dlunivl19-v2dlunivl3881, wgt(w)
kappa2 v2dlunivl19-v2dlunivl3881, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrsoc
drop if v2pepwrsoc == .
  reshape wide v2pepwrsoc, i(country_id historical_date year) j(coder)
*kap v2pepwrsoc19-v2pepwrsoc3879
kap v2pepwrsoc19-v2pepwrsoc3879
kappa2 v2pepwrsoc19-v2pepwrsoc3879, wgt(w)
kappa2 v2pepwrsoc19-v2pepwrsoc3879, wgt(w2)



clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrses
drop if v2pepwrses == .
  reshape wide v2pepwrses, i(country_id historical_date year) j(coder)
kap v2pepwrses19-v2pepwrses3879
kappa2 v2pepwrses19-v2pepwrses3879, wgt(w)
kappa2 v2pepwrses19-v2pepwrses3879, wgt(w2)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrgen
drop if v2pepwrgen == .
  reshape wide v2pepwrgen, i(country_id historical_date year) j(coder)
kap v2pepwrgen19-v2pepwrgen3879
kappa2 v2pepwrgen19-v2pepwrgen3879, wgt(w)
kappa2 v2pepwrgen19-v2pepwrgen3879, wgt(w2)


**Calculate Krippalpha


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2clacjust
drop if v2clacjust == .
  reshape wide v2clacjust, i(country_id historical_date year) j(coder)
krippalpha v2clacjust19 - v2clacjust3882, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2clsocgrp
drop if v2clsocgrp == .
  reshape wide v2clsocgrp, i(country_id historical_date year) j(coder)
krippalpha v2clsocgrp19 - v2clsocgrp3882, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2peedueq
drop if v2peedueq == .
  reshape wide v2peedueq, i(country_id historical_date year) j(coder)
krippalpha v2peedueq19-v2peedueq3879, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pehealth
drop if v2pehealth == .
  reshape wide v2pehealth, i(country_id historical_date year) j(coder)
krippalpha v2pehealth19-v2pehealth3879, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2dlencmps
drop if v2dlencmps == .
  reshape wide v2dlencmps, i(country_id historical_date year) j(coder)
krippalpha v2dlencmps19-v2dlencmps3881, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2dlunivl
drop if v2dlunivl == .
  reshape wide v2dlunivl, i(country_id historical_date year) j(coder)
krippalpha v2dlunivl19-v2dlunivl3881, method(ordinal)

clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrsoc
drop if v2pepwrsoc == .
  reshape wide v2pepwrsoc, i(country_id historical_date year) j(coder)
*kap v2pepwrsoc19-v2pepwrsoc3879
krippalpha v2pepwrsoc19-v2pepwrsoc3879, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrses
drop if v2pepwrses == .
  reshape wide v2pepwrses, i(country_id historical_date year) j(coder)
krippalpha v2pepwrses19-v2pepwrses3879, method(ordinal)


clear
use "v-dem_coder2.dta"

keep country_id historical_date year coder_id v2pepwrgen
drop if v2pepwrgen == .
  reshape wide v2pepwrgen, i(country_id historical_date year) j(coder)
krippalpha v2pepwrgen19-v2pepwrgen3879, method(ordinal)

log close
translate "Table11.smcl" "Table11.log", replace
